package logics 
{
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.events.Event;
	
	import logics.StateMachine;
	
	/**
	 * ...
	 * @author parasitic
	 */
	public class Logic extends MovieClip 
	{
		protected var stg:DisplayObjectContainer;
		public var machine:StateMachine;
	
		protected function delListener(evt:String, f:Function, onStage:Boolean = true):void
		{
			if (onStage)
			{
				stg.removeEventListener(evt, f);
				return;
			}
			removeEventListener(evt, f);
		}
		
		protected function newListener(evt:String, f:Function, onStage:Boolean = true):void
		{
			if (onStage)
			{
				stg.addEventListener(evt, f);
				return;
			}
			addEventListener(evt, f);
		}
		
		protected function init(e:Event):void
		{
			stg = parent;
		}
		
		public function Logic(s:StateMachine=null) 
		{
			machine = s;
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
	}

}